package me.fangsong.timefold.line.constraint;

import ai.timefold.solver.core.api.score.buildin.hardsoft.HardSoftScore;
import ai.timefold.solver.core.api.score.stream.Constraint;
import ai.timefold.solver.core.api.score.stream.ConstraintFactory;
import ai.timefold.solver.core.api.score.stream.ConstraintProvider;
import me.fangsong.timefold.line.domain.Line;

public class PlanConstraintProvider implements ConstraintProvider {

    @Override
    public Constraint[] defineConstraints(ConstraintFactory constraintFactory) {
        return new Constraint[] {
                totalWorkTimeConflict(constraintFactory),
        };
    }

    Constraint totalWorkTimeConflict(ConstraintFactory constraintFactory) {
        return constraintFactory
                .forEach(Line.class).filter(line -> line.getWorkListMinutes()>line.getTotalWorkMinute())
                .penalize(HardSoftScore.ONE_HARD)
                .asConstraint("totalWorkTimeConflict");
    }
}